﻿function addIDStation(listAllStation, combo) {
    removeAllCombo(combo);
    var length = listAllStation.length;
    for (i = 0; i < length; ++i) {
        addElementToCombo(combo, listAllStation[i].IDStation, listAllStation[i].IDStation, false);
    }
}

function addAllBusRoute(listAllRoute, combo) {
    removeAllCombo(combo);
    var lenght = listAllRoute.length;
    for (i = 0; i < lenght; ++i) {
        addElementToCombo(combo, listAllRoute[i].IDBusRoute,listAllRoute[i].BusRouteNumber + "--" + listAllRoute[i].BusRouteName, true);
    }
}
function addElementToCombo(combo, value, text, isSelect) {
    if (value != "" && text != "") {
        var option = document.createElement("option");
        option.text = text;
        option.value = value;
        if (isSelect == true) {
            option.selected = "selected";
        }
        try {
            combo.add(option, null); //Standard         
        } catch (error) {
            combo.add(option); //Standard
        }
    }
}
function setValueToTBRoute(BusRoute) {
    document.getElementById("txt_KiHieu").value= BusRoute.BusRouteNumber;
    document.getElementById("txt_TenTuyen").value = BusRoute.BusRouteName;
    document.getElementById("txt_ChiTiet").value = BusRoute.Stations;
}

function removeAllCombo(combo) {
    var elSel = document.getElementById('selectX');
    for (i = combo.length - 1; i >= 0; i--) {
        combo.remove(i);       
    }
}